<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>YchIzzz</title>
    <!-- 引入layui -->
    <link rel="stylesheet" href="./layui-v2.4.5/layui/css/layui.css" />
    <style>
      .container {
        position: relative;
        margin: 65px auto;
        padding: 8px;
        width: 1020px;
        height: 550px;
        border: 1px solid #000;
      }
      #btn {
        position: absolute;
        right: 9999px;
      }
      #label {
        position: absolute;
        right: 0;
        bottom: 0;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="display"></div>
      <label id="label" for="btn" class="layui-btn layui-btn-normal">点击上传</label>
      <input id="btn" type="file" multiple />
    </div>

    <!-- 引入jQuery -->
    <script src="https://cdn.bootcss.com/jquery/3.4.0/jquery.min.js"></script>
    <!-- 引入layui -->
    <script src="./layui-v2.4.5/layui/layui.js"></script>

    <script>
     
      $("#btn").change(function() {
        let filelist = document.querySelector('#btn').files;
        
        for (let i = 0; i < filelist.length; i++) {
          let blob = new Blob([filelist[i]]);
          let url = window.URL.createObjectURL(blob);
          let img = new Image();
          img.src = url;
          img.width = 540;
          img.height = 300;
          img.style.marginRight = 5 + 'px';
          img.onload = function() {
            $(".display").append(this);
          };
        }
      });
    </script>
  </body>
</html>
